<%--
  Created by IntelliJ IDEA.
  User: argentum
  Date: 2018/11/30
  Time: 22:07
  To change this template use File | Settings | File Templates.
--%>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<html>
<head>
    <!-- jsp文件头和头部 -->
    <%@ include file="../base/top.jsp"%>

    <title>添加课程</title>
</head>
<body class="no-skin">
<div class="main-container ace-save-state" id="main-container">
    <div class="main-content">
        <div class="main-content-inner">
            <div class="page-content">
                <div class="row">
                    <div class="col-xs-12">
                        <!-- PAGE CONTENT BEGINS -->

                        <form class="form-horizontal" role="form" style="display: -webkit-flex;-webkit-justify-content: center;-webkit-align-items: center;">
                            <div style="width: 70%;">
                                <div class="widget-box">
                                    <div class="widget-header" style="text-align: center">
                                        <h4 class="widget-title">添加课程</h4>
                                    </div>

                                    <div class="widget-main">
                                        <div>
                                            <label>课程编号</label>
                                            <br />
                                            <input class="form-control" id="courseNum" maxlength="10" oninput="value=value.replace(/[^\d]/g,'')"/>
                                        </div>
                                        <hr />

                                        <div>
                                            <label>课程名称</label>
                                            <br />
                                            <input class="form-control" id="courseName"/>
                                        </div>
                                        <hr />

                                        <div>
                                            <label >开设学期</label>
                                            <br />
                                            <input class="form-control" id="courseStartTerm" maxlength="1" oninput="value=value.replace(/[^\d]/g,'')"/>
                                        </div>
                                        <hr />

                                        <div>
                                            <label >学分</label>
                                            <br />
                                            <input class="form-control" id="courseCredit">
                                        </div>
                                        <hr />

                                        <div>
                                            <label >学时</label>
                                            <br />
                                            <input class="form-control" id="courseHours" maxlength="3" oninput="value=value.replace(/[^\d]/g,'')">
                                        </div>
                                        <hr />

                                        <div>
                                            <label >课程类别</label>
                                            <br />
                                            <select class="chosen-select form-control" id="courseType" data-placeholder="请选择课程类别...">
                                                <option></option>
                                                <option>通识教育课程</option>
                                                <option>学科基础课程</option>
                                                <option>专业核心课程</option>
                                                <option>专业拓展课程</option>
                                                <option>专业实践课程</option>
                                                <option>创新创业课程</option>
                                            </select>
                                        </div>
                                        <hr />

                                        <div>
                                            <label>考核方式</label>
                                            <br />
                                            <select class="chosen-select form-control" id="courseAssessmentMethod" data-placeholder="请选择考核方式...">
                                                <option></option>
                                                <option>考查</option>
                                                <option>考试</option>
                                                <option>答辩</option>
                                            </select>
                                        </div>
                                        <hr />

                                        <div>
                                            <label>课程描述</label>
                                            <textarea class="form-control" id="courseDescription" maxlength="100" style="height: 80px;resize:none;" placeholder="仅限100字..."></textarea>
                                        </div>

                                        <div class="clearfix form-actions" align="center">
                                            <button class="btn btn-info" type="button" onclick="addCourse()">
                                                Submit
                                            </button> &nbsp; &nbsp; &nbsp;
                                            <button class="btn" type="reset">
                                                Reset
                                            </button>
                                        </div>
                                    </div>
                                </div>
                            </div>
                        </form>

                    </div>
                    <!-- /.col -->
                </div>
                <!-- /.row -->
            </div>
            <!-- /.page-content -->
        </div>
    </div><!-- /.main-content -->
    <!-- 返回顶部 -->
    <a href="#" id="btn-scroll-up" class="btn-scroll-up btn btn-sm btn-inverse">
        <i class="ace-icon fa fa-angle-double-up icon-only bigger-110"></i>
    </a>
</div>
<!-- basic scripts -->
<!-- 页面底部js¨ -->
<%@ include file="../base/foot.jsp"%>


<script type="text/javascript">
   // $(top.hangge());//关闭加载状态


       $(function () {
           //下拉框
           if (!ace.vars['touch']) {
               $('.chosen-select').chosen({allow_single_deselect: true});
               $(window)
                   .off('resize.chosen')
                   .on('resize.chosen', function () {
                       $('.chosen-select').each(function () {
                           var $this = $(this);
                           $this.next().css({'width': $this.parent().width()});
                       });
                   }).trigger('resize.chosen');
               $(document).on('settings.ace.chosen', function (e, event_name, event_val) {
                   if (event_name != 'sidebar_collapsed') return;
                   $('.chosen-select').each(function () {
                       var $this = $(this);
                       $this.next().css({'width': $this.parent().width()});
                   });
               });
               $('#chosen-multiple-style .btn').on('click', function (e) {
                   var target = $(this).find('input[type=radio]');
                   var which = parseInt(target.val());
                   if (which == 2) $('#form-field-select-4').addClass('tag-input-style');
                   else $('#form-field-select-4').removeClass('tag-input-style');
               });
           }
       });


   function addCourse(){
      var course ={};
      course.talentTrainingProgramId = "${talentTrainingProgramId}",
      course.courseNum = $("#courseNum").val();
      course.courseName = $("#courseName").val();
      course.courseCredit = $("#courseCredit").val();
      course.courseHours = $("#courseHours").val();
      course.courseAssessmentMethod = $("#courseAssessmentMethod").val();
      course.courseType= $("#courseType").val(),
      course.courseStartTerm = $("#courseStartTerm").val();
      course.courseDescription = $("#courseDescription").val();
      $.ajax({
          type:"post",
          url:"<%=basePath%>course/addCourse",
          data:course,
          dataType:'json',
          success:function (data) {
              prompt_alert('success',data["msg"],0);
              if(data["success"]==true){
                  $("#success").val("true");
              }else{
                  $("#success").val("false");
              }
          },
          error:function (){
              prompt_alert('error',"添加失败",0);
          },

      });
  }
</script>

</body>
</html>
